let myNew = function(constrouct,...props) {
    let context = Object.create(constrouct.prototype);

    let result = constrouct.apply(context,props);

    return (typeof result === 'object' && result !== null) ? result : context;

}


function Person(name) {
    this.name = name;
}

let obj = myNew(Person,'daxia');
console.log(obj); // {name:'daxia}

// console.log(myNew(Set,[1,2,2,3])); 
// 会有如下报错：
// let result = constrouct.apply(context,props);
// ^
// TypeError: Constructor Set requires 'new'


